package judesart.app.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Entity
@NamedQueries( {
        @NamedQuery(name = "Artwork.countByArtistId", query = "select count(o) from Artwork o where o.artistId = :artistId"),
        @NamedQuery(name = "Artwork.findByArtistId", query = "select o from Artwork o where o.artistId = :artistId"),
        @NamedQuery(name = "Artwork.findIdsByArtistId", query = "select o.id from Artwork o where o.artistId = :artistId") })
public class Artwork implements Serializable
{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Basic
    private Long artistId;
    @Basic
    @NotNull
    private String title;
    @Basic
    private String description;
    @Basic
    @NotNull
    private String dimensions;
    @Basic
    @Min(value = 1966)
    private long year;
    @Basic
    @Enumerated(EnumType.STRING)
    @NotNull
    private ArtworkType type;
    @Basic
    @NotNull
    private String technic;
    @Basic
    private List<String> tags;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "artwork")
    private List<ArtworkPhoto> photos;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getArtistId()
    {
        return artistId;
    }

    public void setArtistId(Long artistId)
    {
        this.artistId = artistId;
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getDimensions()
    {
        return dimensions;
    }

    public void setDimensions(String dimensions)
    {
        this.dimensions = dimensions;
    }

    public long getYear()
    {
        return year;
    }

    public void setYear(long year)
    {
        this.year = year;
    }

    public ArtworkType getType()
    {
        return type;
    }

    public void setType(ArtworkType type)
    {
        this.type = type;
    }

    public String getTechnic()
    {
        return technic;
    }

    public void setTechnic(String technic)
    {
        this.technic = technic;
    }

    public List<String> getTags()
    {
        return tags;
    }

    public void setTags(List<String> tags)
    {
        this.tags = tags;
    }

    public List<ArtworkPhoto> getPhotos()
    {
        return photos;
    }

    public void setPhotos(List<ArtworkPhoto> photos)
    {
        this.photos = photos;
    }
}
